package com.walle.concurrenttest.pattern.activeobject;

/**
 * @author zhangjiapeng
 * @Package com.walle.concurrenttest.pattern.activeobject
 * @Description: ${todo}
 * @date 2019/2/27 15:40
 */
public class Proxy implements ActiveObject{

    private final SchedulerThread schedulerThread;
    private final Servant servant;

    public Proxy(SchedulerThread schedulerThread, Servant servant) {
        this.schedulerThread = schedulerThread;
        this.servant = servant;
    }

    @Override
    public Result<String> makeString(int count, char fillChar) {
        FutureResult<String> futureResult = new FutureResult<>();
        schedulerThread.invoke(new MakeStringRequest(servant,futureResult,count,fillChar));
        return futureResult;
    }

    @Override
    public void displayString(String s) {
        schedulerThread.invoke(new DisplayStringRequest(servant,s));
    }
}
